package coroutines.exception

import kotlinx.coroutines.*
import java.lang.RuntimeException

class CoroutineExceptionTest2 {
}

fun main() {
    runBlocking {
        val scope = CoroutineScope(Job())

        scope.launch {
            launch(SupervisorJob() + CoroutineExceptionHandler { _, _ -> }) {
                println("子协程A开始")
                delay(100)
                println("子协程抛出异常")
                throw RuntimeException("子协程A抛出的异常")
            }

            launch {
                println("子协程B开始执行")
                delay(200)
                throw RuntimeException("子协程B抛出的异常")
                println("协程B执行完毕")
            }
        }

        delay(1000)

        println("父协程结束了")
    }
}